﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ViewModel="clr-namespace:DataForest.ViewModel"
        xmlns:View="clr-namespace:DataForest.View"
        xmlns:Dialog="clr-namespace:DataForest.View.Dialogs"
        x:Class="DataForest.MainWindowView"
        Title="DataForest" Height="657" Width="977" Background="#FF005207">
    <Window.Resources>
        <Style TargetType="Button" x:Key="CloseButton">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Image Margin="5,0" x:Name="CloseImage" Source="Icons/tab-close-inactive.png" Width="12" Height="12" RenderOptions.BitmapScalingMode="HighQuality"/>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="CloseImage" Property="Source" Value="Icons/tab-close.png" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    
    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="22" />
                <RowDefinition Height="368*" />
                <RowDefinition Height="33" />
            </Grid.RowDefinitions>
            <Menu Height="23" x:Name="menu1" VerticalAlignment="Top" Grid.RowSpan="2">
                <MenuItem Header="Datei">
                    <MenuItem Header="Neu" >
                        <MenuItem.Icon>
                            <Image Source="Icons/table-add.png" Width="16" Height="16" RenderOptions.BitmapScalingMode="HighQuality"/>
                        </MenuItem.Icon>
                        <MenuItem Header="Tabelle" Command="{Binding NewTableCommand}"/>
                        <MenuItem Header="Baum" Command="{Binding NewTreeCommand}"/>
                    </MenuItem>
                    <MenuItem Header="Öffnen" Command="{Binding OpenCommand}">
                        <MenuItem.Icon>
                            <Image Source="Icons/document-open.png" Width="16" Height="16" RenderOptions.BitmapScalingMode="HighQuality"></Image>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Speichern" Command="{Binding SaveCommand}">
                        <MenuItem.Icon>
                            <Image Source="Icons/document-save.png" Width="16" Height="16" RenderOptions.BitmapScalingMode="HighQuality"></Image>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Speichern unter..." Command="{Binding SaveAsCommand}">
                        <MenuItem.Icon>
                            <Image Source="Icons/document-save-as.png" Width="16" Height="16" RenderOptions.BitmapScalingMode="HighQuality"></Image>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Beenden" Command="{Binding CloseCommand}">
                        <MenuItem.Icon>
                            <Image Source="Icons/tab-close.png" Width="16" Height="16" RenderOptions.BitmapScalingMode="HighQuality"></Image>
                        </MenuItem.Icon>
                    </MenuItem>
                </MenuItem>
                <MenuItem Header="Baumdarstellung">
                    <MenuItem Header="Baum interaktiv" Command="{Binding CreateInteractiveTreeCommand}">
                        <MenuItem.Icon>
                            <Image Source="Icons/tree.png" Width="16" Height="16" RenderOptions.BitmapScalingMode="HighQuality"></Image>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Baum automatisch" Command="{Binding CreateOptimalTreeCommand}">
                        <MenuItem.Icon>
                            <Image Source="Icons/tree-auto.png" Width="16" Height="16" RenderOptions.BitmapScalingMode="HighQuality"></Image>
                        </MenuItem.Icon>
                    </MenuItem>
                </MenuItem>
            </Menu>
            <TabControl x:Name="tabControl1" Grid.RowSpan="2" Grid.Row="1" ItemsSource="{Binding Tabs}" SelectedItem="{Binding SelectedTab}" >
                <TabControl.Resources>
                   <Style TargetType="{x:Type TabItem}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type TabItem}">
                                    <Border CornerRadius="2,2,0,0" BorderBrush="DarkGray" BorderThickness="1,1,1,0" Padding="2,0,0,0" Background="{Binding Group.BackgroundBrush, FallbackValue=GhostWhite}">
                                    <StackPanel Orientation="Horizontal" Height="25" x:Name="tabItemPanel">
                                        <ContentControl Content="{Binding}" VerticalContentAlignment="Center">
                                            <ContentControl.Resources>
                                                <DataTemplate DataType="{x:Type ViewModel:TableTabModel}">
                                                    <StackPanel Orientation="Horizontal">
                                                        <Image Source="Icons/table.png" Width="16" Height="16" Stretch="Fill" RenderOptions.BitmapScalingMode="HighQuality" Margin="0,0,10,0" />
                                                            <TextBlock  Text="{Binding Group.Table.DisplayName}" x:Name="textTableName"  VerticalAlignment="Center"/>
                                                    </StackPanel>
                                                </DataTemplate>
                                                <DataTemplate DataType="{x:Type ViewModel:TreeTabModel}">
                                                    <StackPanel Orientation="Horizontal">
                                                        <Image Source="Icons/tree.png" Width="16" Height="16" Stretch="Fill" RenderOptions.BitmapScalingMode="HighQuality" Margin="0,0,10,0" />
                                                            <TextBlock Text="{Binding Tree.DisplayName}" x:Name="textTreeName" VerticalAlignment="Center"/>
                                                    </StackPanel>
                                                    </DataTemplate>
                                                <DataTemplate DataType="{x:Type ViewModel:StartTabViewModel}">
                                                    <TextBlock Margin="5,0,0,0" Text="Startseite" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                                </DataTemplate>
                                            </ContentControl.Resources>
                                        </ContentControl>
                                        <Button Margin="15,0,0,0" Style="{StaticResource CloseButton}" Command="{Binding CloseTabCommand}" HorizontalAlignment="Right" VerticalAlignment="Center"/>
                                        </StackPanel>
                                    </Border>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsSelected" Value="True">
                                            <Setter Property="Panel.ZIndex" Value="100" />
                                            <Setter Property="Margin" Value="0,0,0,-1" />
                                            <Setter Property="Foreground" Value="Black" />
                                            <Setter Property="FontWeight" Value="Bold" />
                                        </Trigger>
                                        <Trigger Property="IsSelected" Value="False">
                                            <Setter Property="Foreground" Value="Gray" />
                                            <Setter Property="FontWeight" Value="Bold" />
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </TabControl.Resources>
                
                <TabControl.ContentTemplate>
                    <DataTemplate>
                        <ContentControl Content="{Binding}">
                            <ContentControl.Resources>
                                <DataTemplate DataType="{x:Type ViewModel:TableTabModel}">
                                    <View:TableView />
                                </DataTemplate>
                                <DataTemplate DataType="{x:Type ViewModel:TreeTabModel}">
                                    <View:TreeView/>
                                </DataTemplate>
                                <DataTemplate DataType="{x:Type ViewModel:StartTabViewModel}">
                                    <View:StartTabView/>
                                </DataTemplate>
                            </ContentControl.Resources>
                        </ContentControl>
                    </DataTemplate>
                </TabControl.ContentTemplate>
            </TabControl>
        </Grid>
    </Grid>
</Window>